home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 3 / Your Choice Software Collection 3.iso / os2 / gbase / install.001 / GUIRUN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  40.0 KB  |  873 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *    File:         GUIRUN.H                                               *
  4.  *                                                                         *
  5.  *    Description:  This header file contains the function prototypes      *
  6.  *                  and data structures required for the generated         *
  7.  *                  runtime code.                                          *
  8.  *                                                                         *
  9.  *    Copyright:    (C) Copyright 1993 JBA International, plc.             *
  10.  *                  All Rights Reserved Worldwide.                         *
  11.  *                                                                         *
  12.  ***************************************************************************/
  13.  
  14. #ifndef H_GUIRUN
  15. #define H_GUIRUN
  16.  
  17. #include <iostream.h>
  18.  
  19.  
  20. /***************************************************************************
  21.  *    Miscellaneous macros/messages.                                       *
  22.  ***************************************************************************/
  23.  
  24. #define WM_GUIDATAINDEX      WM_USER+1           /* Get window words index */
  25. #define WM_GUIGETWINDOW      WM_USER+2           /* Get window information */
  26. #define WM_GUIGETPROPERTY    WM_USER+3           /* Get window property    */
  27. #define WM_GUISETPROPERTY    WM_USER+4           /* Set window property    */
  28. #define WM_GUIWINDOWLOADED   WM_USER+5           /* Window has been loaded */
  29. #define WM_GUIPARENTRESIZED  WM_USER+6           /* Parent has resized     */
  30. #define WM_GUITHREADENDED    WM_USER+7           /* Thread ended           */
  31. #define WM_GUISHUTDOWN       WM_USER+8           /* Shutdown detected      */
  32. #define WM_GUISETHELPFILE    WM_USER+9
  33.                                                  /* DDE messages           */
  34. #define WM_GUIDDEACK         WM_USER+10          /* DDE Acknowledge        */
  35. #define WM_GUIDDEADVISE      WM_USER+11          /* DDE Advise Request     */
  36. #define WM_GUIDDEDATA        WM_USER+12          /* DDE Data Message       */
  37. #define WM_GUIDDEEXECUTE     WM_USER+13          /* DDE Execute Request    */
  38. #define WM_GUIDDEINITIATE    WM_USER+14          /* DDE Initiate Request   */
  39. #define WM_GUIDDEINITIATEACK WM_USER+15          /* DDE Initiate Ack.      */
  40. #define WM_GUIDDEPOKE        WM_USER+16          /* DDE Poke Request       */
  41. #define WM_GUIDDEREQUEST     WM_USER+17          /* DDE Request Message    */
  42. #define WM_GUIDDETERMINATE   WM_USER+18          /* DDE Terminate Request  */
  43. #define WM_GUIDDEUNADVISE    WM_USER+19          /* DDE Unadvise Request   */
  44.  
  45. #define WM_GUIUSER           WM_USER+20          /* Last GUI message       */
  46.  
  47. #define FOREVER              GuiForever()
  48. #define PMENTRY              MRESULT APIENTRY
  49.  
  50. #define IDHT_GUIMAIN         4000                /* Main help table ID     */
  51.  
  52.  
  53. /***************************************************************************
  54.  *    Window word offsets for mandatory values.                            *
  55.  ***************************************************************************/
  56.  
  57. #define QWS_ORIGXPOS         0                   /* Unscaled X position    */
  58. #define QWS_ORIGYPOS         2                   /* Unscaled Y position    */
  59. #define QWS_ORIGWIDTH        4                   /* Unscaled width         */
  60. #define QWS_ORIGHEIGHT       6                   /* Unscaled height        */
  61. #define QWL_MOUSEIMG         8                   /* Mouse pointer type     */
  62. #define QWL_MOUSEPTR         12                  /* Mouse pointer handle   */
  63. #define QWL_GUIUSER          16                  /* Start of user words    */
  64.  
  65.  
  66. /*************************************************************************** 
  67.  *    System window/control class constants.                               *
  68.  ***************************************************************************/
  69.  
  70. #define WC_GUIBUTTON         "GUIBUTTON"
  71. #define WC_GUICOMBOBOX       "GUICOMBOBOX"
  72. #define WC_GUIENTRYFIELD     "GUIENTRYFIELD"
  73. #define WC_GUILISTBOX        "GUILISTBOX"
  74. #define WC_GUIMLE            "GUIMLE"
  75. #define WC_GUISCROLLBAR      "GUISCROLLBAR"
  76. #define WC_GUISTATIC         "GUISTATIC"
  77.  
  78.  
  79. /***************************************************************************
  80.  *   Standard window/control names.                                        *
  81.  ***************************************************************************/
  82.  
  83. #define WT_UNKNOWN           "Unknown"
  84. #define WT_DESKTOP           "Desktop"
  85. #define WT_OBJECT            "Object"
  86. #define WT_FRAME             "Frame"
  87. #define WT_DIALOG            "Dialog"
  88. #define WT_CLIENT            "Client"
  89. #define WT_SYSMENU           "System Menu"
  90. #define WT_MENUBAR           "Menu Bar"
  91. #define WT_SUBMENU           "Sub Menu"
  92. #define WT_MENUITEM          "Menu Item"
  93. #define WT_PUSHBUTTON        "Push Button"
  94. #define WT_RADIOBUTTON       "Radio Button"
  95. #define WT_CHECKBOX          "Checkbox"
  96. #define WT_3STATE            "3-State Checkbox"
  97. #define WT_USERBUTTON        "User Button"
  98. #define WT_COMBOBOX          "Combobox"
  99. #define WT_ENTRYFIELD        "Entry Field"
  100. #define WT_LISTBOX           "Listbox"
  101. #define WT_MLE               "Multi-Line Entry"
  102. #define WT_VSCROLL           "Vert. Scrollbar"
  103. #define WT_HSCROLL           "Horz. Scrollbar"
  104. #define WT_STATICTEXT        "Static Text"
  105. #define WT_GROUPBOX          "Group Box"
  106. #define WT_STATICICON        "Icon"
  107. #define WT_STATICSYSICON     "System Icon"
  108. #define WT_STATICBITMAP      "Bitmap"
  109. #define WT_STATICRECT        "Rectangle"
  110. #define WT_CUSTOM            "Custom Control"
  111.  
  112.  
  113. /*************************************************************************** 
  114.  *    System window/control property identifiers.                          *
  115.  ***************************************************************************/
  116.  
  117. #define WPID_NAME            0                   /* Window name            */
  118. #define WPID_ID              1                   /* Window ID              */
  119. #define WPID_PARENT          2                   /* Window parent          */
  120. #define WPID_OWNER           3                   /* Window owner           */
  121. #define WPID_XPOS            4                   /* Window X position      */
  122. #define WPID_YPOS            5                   /* Window Y position      */
  123. #define WPID_WIDTH           6                   /* Window width           */
  124. #define WPID_HEIGHT          7                   /* Window height          */
  125. #define WPID_STYLE           8                   /* Window style flags     */
  126. #define WPID_HELP            9                   /* Window help name       */
  127. #define WPID_TEXT            10                  /* Window text            */
  128. #define WPID_VISIBLE         11                  /* Window visible?        */
  129. #define WPID_ENABLED         12                  /* Window enabled?        */
  130. #define WPID_UPDATE          13                  /* Window update enabled? */
  131. #define WPID_MOUSEPTR        14                  /* Window mouse pointer   */
  132. #define WPID_USER            15                  /* Last system property   */
  133.  
  134.  
  135. /***************************************************************************
  136.  *    Property indexes for some of the system controls.                    *
  137.  ***************************************************************************/
  138.  
  139. #define WPID_FRAMEFLAGS      WPID_USER+0         /* Frame flags            */
  140. #define WPID_FRAMEMEMOPTIONS WPID_USER+1         /* Frame memory options   */
  141. #define WPID_FRAMEICON       WPID_USER+2         /* Frame icon name        */
  142. #define WPID_FRAMESOURCE     WPID_USER+3         /* Frame source file      */
  143.  
  144. #define WPID_BUTTONCHECKED   WPID_USER+0         /* Button checked         */
  145. #define WPID_BUTTONRESOURCE  WPID_USER+1         /* Button resource name   */
  146. #define WPID_BUTTONDEFAULT   WPID_USER+2         /* Button default         */
  147.  
  148. #define WPID_CUSTOMCLASS     WPID_USER+0         /* Custom class name      */
  149.  
  150. #define WPID_ENTRYMAXLENGTH  WPID_USER+0         /* Entry field max length */
  151. #define WPID_ENTRYMINSEL     WPID_USER+1         /* Entry field min sel.   */
  152. #define WPID_ENTRYMAXSEL     WPID_USER+2         /* Entry field max sel.   */
  153.  
  154. #define WPID_LISTBOXCOUNT    WPID_USER+0         /* Listbox count          */
  155. #define WPID_LISTBOXSEL      WPID_USER+1         /* Listbox selection      */
  156. #define WPID_LISTBOXTOP      WPID_USER+2         /* Listbox top            */
  157.  
  158. #define WPID_MENUFLAGS       WPID_USER+0         /* Menu flags             */
  159. #define WPID_MENUPOSITION    WPID_USER+1         /* Menu position          */
  160. #define WPID_MENUBITMAP      WPID_USER+2         /* Menu bitmap            */
  161. #define WPID_MENUACCELFLAGS  WPID_USER+3         /* Menu accel flags       */
  162. #define WPID_MENUACCELKEY    WPID_USER+4         /* Menu accel key         */
  163. #define WPID_MENUCHECKED     WPID_USER+5         /* Menu checked           */
  164.  
  165. #define WPID_SCROLLMIN       WPID_USER+0         /* Scrollbar minimum      */
  166. #define WPID_SCROLLMAX       WPID_USER+1         /* Scrollbar maximum      */
  167. #define WPID_SCROLLPOS       WPID_USER+2         /* Scrollbar position     */
  168.  
  169. #define WPID_STATICRESOURCE  WPID_USER+0         /* Static resource name   */
  170.  
  171.  
  172. /***************************************************************************
  173.  *   Data type constants.                                                  *
  174.  ***************************************************************************/
  175.  
  176. #define DT_VOID              0x00000000L         /* Void         (no type) */
  177. #define DT_SHORT             0x00000001L         /* Short          (short) */
  178. #define DT_LONG              0x00000002L         /* Long            (long) */
  179. #define DT_INT               0x00000003L         /* int    (Short or Long) */
  180. #define DT_SREAL             0x00000004L         /* Short Real     (float) */
  181. #define DT_REAL              0x00000008L         /* Real          (double) */
  182. #define DT_LREAL             0x00000010L         /* Long Real(long double) */
  183. #define DT_SCALED            0x00000020L         /* Scaled integer (zoned) */
  184. #define DT_NUM               0x000000FFL         /* Numeric type           */
  185. #define DT_STRING            0x00000100L         /* String string (char *) */
  186. #define DT_WINDOW            0x00000200L         /* Window information     */
  187. #define DT_IMAGE             0x00000400L         /* Image type             */
  188. #define DT_MESSAGE           0x00000800L         /* Message type           */
  189. #define DT_CHAR              0x00001000L         /* Character type         */
  190. #define DT_USER              0x00008000L         /* User data type         */
  191. #define DT_THREAD            0x00010000L         /* Thread information     */
  192. #define DT_MODULE            0x00020000L         /* Module routine address */
  193. #define DT_STRUCT            0x00040000L         /* Structure              */
  194. #define DT_ANYSTRUCT         0x00080000L         /* Any structure          */
  195. #define DT_ANY               0x000FFFFFL         /* Any type               */
  196.  
  197. #define DT_MASK(x)           (x & DT_ANY)
  198.  
  199.  
  200. /*************************************************************************** 
  201.  *    REAL data types.                                                     *
  202.  ***************************************************************************/
  203.  
  204. typedef float       SREAL, *PSREAL;
  205. typedef double      REAL,  *PREAL;
  206. typedef long double LREAL, *PLREAL;
  207.  
  208.  
  209. /*************************************************************************** 
  210.  *    Window data type.                                                    *
  211.  ***************************************************************************/
  212.  
  213. typedef struct _WINDOW
  214.         {
  215.         char    szType [20+1];                   /* Window type            */
  216.         LONG    lID;                             /* Window ID              */
  217.         HWND    hwnd;                            /* Window handle          */
  218.         HWND    hwndClient;                      /* Window client          */
  219.         HWND    hwndParent;                      /* Window parent          */
  220.         PFNWP   pfnwp;                           /* Window procedure       */
  221.         HMODULE hModule;                         /* Resource module        */
  222.         }
  223.         WINDOW, *PWINDOW;
  224.  
  225.  
  226. /*************************************************************************** 
  227.  *    Message data type.                                                   *
  228.  ***************************************************************************/
  229.  
  230. typedef struct _MESSAGE
  231.         {
  232.         LONG  lMsgID;                            /* Message ID             */
  233.         ULONG ulOptions;                         /* Message display options*/
  234.         }
  235.         MESSAGE, *PMESSAGE;
  236.  
  237.  
  238. /***************************************************************************
  239.  *    The String class provides support for the JOT string data type.      *
  240.  *    It allows concatenation via the + operator and supports              *
  241.  *    manipulation of fixed length string buffers.                         *
  242.  ***************************************************************************/
  243.  
  244. class String 
  245.       {
  246.       public:
  247.       // Constructors and destructor
  248.       String ();
  249.      ~String ();
  250.       String (const String& sString);
  251.       String (const char *pszStr);
  252.       String (const char cChar);
  253.       String (const char *pBuffer, int iSize);
  254.  
  255.       // Conversion operators
  256.       operator char () const;
  257.       operator void *() const;
  258.       operator char *() const;
  259.       operator const char *() const;
  260.  
  261.       // Assignment operators
  262.       String& operator= (const String& sString);
  263.       String& operator= (const char *pszStr);
  264.       String& operator= (const char cChar);
  265.  
  266.       // Comparison operators
  267.       friend int operator== (const String& sString1, const String& sString2);
  268.       friend int operator!= (const String& sString1, const String& sString2);
  269.       friend int operator>  (const String& sString1, const String& sString2);
  270.       friend int operator<  (const String& sString1, const String& sString2);
  271.       friend int operator>= (const String& sString1, const String& sString2);
  272.       friend int operator<= (const String& sString1, const String& sString2);
  273.  
  274.       // Stream operators 
  275.       friend ostream& operator << (ostream& stream, const String& sString);
  276.       friend istream& operator >> (istream& stream, String& sString);
  277.  
  278.       // Concatenation operators
  279.       friend String operator+ (const String& sString1, const String& sString2);
  280.  
  281.       // Utility member functions
  282.       friend int GuiStrLen (const String& sString);
  283.       friend String GuiChr (int iAscii);
  284.       friend int GuiAsc (const String& sChar);
  285.       friend String GuiStr (int iNumber);
  286.       friend String GuiStr (short sNumber);
  287.       friend String GuiStr (long lNumber);
  288.       friend String GuiStr (float fNumber);
  289.       friend String GuiStr (double dNumber);
  290.       friend String GuiStr (long double ldNumber);
  291.       friend String GuiStrLower (const String& sString);
  292.       friend String GuiStrUpper (const String& sString);
  293.       friend String GuiStrLeft (const String& sString, int iSize);
  294.       friend String GuiStrMid (const String& sString, int iStart, int iSize);
  295.       friend String GuiStrRight (const String& sString, int iSize);
  296.       friend String GuiStrTrim (const String& sString);
  297.       friend String GuiStrLTrim (const String& sString);
  298.       friend String GuiStrRTrim (const String& sString);
  299.       friend String GuiStrRepeat (const String& sChar, int iCount);
  300.       friend int GuiStrSearch (const String& sString, const String& sSubString, int iStart);
  301.       friend void GuiStrFill (char *pBuffer, int iSize, const String& sString);
  302.       friend String GuiToString (const void *pStruct, int iSize);
  303.       friend void *GuiToStruct (String *psString, int iSize);
  304.  
  305.       protected:
  306.       // Internal routines
  307.       friend int GuiStrCmp (const char *, const char *);
  308.  
  309.       // Internal representation (ASCIIZ string) 
  310.       char *psz;
  311.       };
  312.  
  313.  
  314. /***************************************************************************
  315.  *    The Scaled class provides support for the JOT scaled integer         *
  316.  *    data type. It provides support for arbitrary precision numbers.      *
  317.  ***************************************************************************/
  318.  
  319. class Scaled
  320.       {
  321.       public:
  322.       // Constructors and destructor
  323.       Scaled ();
  324.      ~Scaled ();
  325.       Scaled (const Scaled& sNumber);
  326.       Scaled (const char *pszNumber);
  327.       Scaled (short sNumber);
  328.       Scaled (int iNumber);
  329.       Scaled (long lNumber);
  330.       Scaled (float fNumber);
  331.       Scaled (double dNumber);
  332.       Scaled (long double ldNumber);
  333.       Scaled (char *pZoned, int iSize, int iDecPlaces);
  334.  
  335.       // Conversion operators
  336.       operator char *() const;
  337.       operator const char *() const;
  338.       operator short() const;
  339.       operator long() const;
  340.       operator float() const;
  341.       operator double() const;
  342.       operator long double() const;
  343.  
  344.       // Assignment operators
  345.       Scaled& operator= (const char *pszNumber);
  346.       Scaled& operator= (const Scaled& sNumber);
  347.  
  348.       // Comparison operators
  349.       friend int operator == (const Scaled& sNum1, const Scaled& sNum2);
  350.       friend int operator != (const Scaled& sNum1, const Scaled& sNum2);
  351.       friend int operator >  (const Scaled& sNum1, const Scaled& sNum2);
  352.       friend int operator <  (const Scaled& sNum1, const Scaled& sNum2);
  353.       friend int operator >= (const Scaled& sNum1, const Scaled& sNum2);
  354.       friend int operator <= (const Scaled& sNum1, const Scaled& sNum2);
  355.  
  356.       // Stream operators 
  357.       friend ostream& operator << (ostream& stream, const Scaled& sNumber);
  358.       friend istream& operator >> (istream& stream, Scaled& sNumber);
  359.  
  360.       // Mathematical operators
  361.       friend Scaled operator+ (const Scaled& sNum1, const Scaled& sNum2);
  362.       friend Scaled operator- (const Scaled& sNum1, const Scaled& sNum2);
  363.       friend Scaled operator* (const Scaled& sNum1, const Scaled& sNum2);
  364.       friend Scaled operator/ (const Scaled& sNum1, const Scaled& sNum2);
  365.  
  366.       // Unary - operator 
  367.       friend Scaled operator- (const Scaled& sNumber);
  368.  
  369.       // Utility functions
  370.       friend Scaled GuiMod (const Scaled& sNum1, const Scaled& sNum2);
  371.       friend Scaled GuiVal (const char *pszNumber);
  372.       friend String GuiStr (const Scaled& sNumber);
  373.       friend Scaled GuiAbs (const Scaled& sNumber);
  374.       friend Scaled GuiInt (const Scaled& sNumber);
  375.       friend Scaled GuiFrac (const Scaled& sNumber);
  376.       friend Scaled GuiCeil (const Scaled& sNumber);
  377.       friend Scaled GuiFloor (const Scaled& sNumber);
  378.  
  379.       void Round (long);
  380.       void Length (long&, long&) const;
  381.  
  382.       // Internal routines.
  383.       protected:
  384.       char GetDigit (long) const;
  385.       BOOL SetDigit (long, char);
  386.       BOOL MoreDigits (long);
  387.       BOOL SizeDigits (long);
  388.       friend void GuiScaledStrip (Scaled&);
  389.       friend void GuiScaledAlign (Scaled&, Scaled&);
  390.       friend void GuiScaledAdd (Scaled&, Scaled&, Scaled&);
  391.       friend void GuiScaledSub (Scaled&, Scaled&, Scaled&);
  392.       friend void GuiScaledMul (Scaled&, Scaled&, Scaled&);
  393.       friend void GuiScaledDiv (Scaled&, Scaled&, Scaled&);
  394.       friend long GuiArrayAdd  (char *, char *, long);
  395.       friend long GuiArraySub  (char *, char *, long);
  396.       friend long GuiArrayMul  (char *, char *, long, long);
  397.       friend int  GuiScaledCmp (const Scaled&, const Scaled&);
  398.       friend void GuiFmtZoned (char *, int, int, const Scaled&);
  399.  
  400.       // Internal representation variables.
  401.       long  lSign;                          /* Sign of number              */
  402.       long  lTotal;                         /* Total number of digits      */
  403.       long  lDec;                           /* Total number of decimals    */
  404.       long  lAlloc;                         /* Total size allocated        */
  405.       char *pDigits;                        /* Digits array                */
  406.       };
  407.  
  408.  
  409. /***************************************************************************
  410.  *    Macro for defining encoded ZONED fields within structures.           *
  411.  ***************************************************************************/
  412.  
  413. #define SCALED(name,len,dec) char name[len]
  414.  
  415.  
  416. /***************************************************************************
  417.  *    The Image class provides support for the JOT IMAGE data type.        *
  418.  ***************************************************************************/
  419.  
  420. // Image reference counting class
  421. class ImageRef
  422.       {
  423.       // Friend of Image
  424.       friend class Image;
  425.  
  426.       private:
  427.       // Constructor & destructor
  428.       ImageRef ();
  429.       ImageRef (ULONG, ULONG);
  430.      ~ImageRef ();
  431.  
  432.       // Internal routines
  433.       #ifdef INCL_PM
  434.       friend ULONG GuiMakeImage  (ULONG, LONG, HMODULE);
  435.       friend void  GuiFreeImage  (ImageRef&);
  436.       friend ULONG GuiLoadImage  (char *, PULONG);
  437.       friend ULONG GuiLoadIcon   (PBYTE, LONG, PBITMAPFILEHEADER2, BOOL);
  438.       friend ULONG GuiLoadBitmap (PBYTE, LONG, PBITMAPFILEHEADER2);
  439.       friend ULONG GuiCopyIcon   (HPOINTER);
  440.       friend ULONG GuiCopyBitmap (HBITMAP);
  441.       #endif /* INCL_PM */
  442.  
  443.       // Internal variables
  444.       LONG  lCount;                        /* Image refernce count   */
  445.       ULONG ulType;                        /* Image type             */
  446.       ULONG ulHandle;                      /* Image handle           */
  447.       };
  448.  
  449. class Image 
  450.       {
  451.       public:
  452.       // Constructors and destructor
  453.       Image ();
  454.      ~Image ();
  455.       Image (const Image& img);
  456.       Image (ULONG ulType, LONG lResourceID, HMODULE hModule);
  457.       Image (ULONG ulType, LHANDLE hHandle);
  458.       Image (const String& sFileName);
  459.       Image (char *pszFileName);
  460.  
  461.       // Assignment operators
  462.       Image& operator= (const Image& img);
  463.       Image& operator= (const char *pszFileName);
  464.  
  465.       // Comparison operators
  466.       friend int operator== (const Image& img1, const Image& img2);
  467.       friend int operator!= (const Image& img1, const Image& img2);
  468.  
  469.       // Access members
  470.       ULONG   Type   (void) const;
  471.       LHANDLE Handle (void) const;
  472.       void    GetSize (LONG *, LONG *);
  473.  
  474.       protected:
  475.       // Internal variables
  476.       ImageRef *pRef;                            /* Reference pointer      */
  477.       };
  478.  
  479.  
  480. /***************************************************************************
  481.  *    Image types.                                                         *
  482.  ***************************************************************************/
  483.  
  484. #define GUIIMG_UNKNOWN       0                   /* Unknown image type     */
  485. #define GUIIMG_ICON          1                   /* Icon image             */
  486. #define GUIIMG_POINTER       2                   /* Pointer image          */
  487. #define GUIIMG_SYSPOINTER    3                   /* System pointer image   */
  488. #define GUIIMG_BITMAP        4                   /* Bitmap image           */
  489. #define GUIIMG_SYSBITMAP     5                   /* System bitmap image    */
  490. #define GUIIMG_METAFILE      6                   /* Metafile image         */
  491.  
  492.  
  493. /***************************************************************************
  494.  *    Image drawing flags.                                                 *
  495.  ***************************************************************************/
  496.  
  497. #define GUIDRW_NORMAL        0x00000000          /* Draw normal            */
  498. #define GUIDRW_HALFTONED     0x00000001          /* Draw half-toned        */
  499. #define GUIDRW_INVERTED      0x00000002          /* Draw inverted          */
  500. #define GUIDRW_STRETCHED     0x00000004          /* Draw stretched         */
  501.  
  502.  
  503. /***************************************************************************
  504.  *    Code module data type.                                               *
  505.  ***************************************************************************/
  506.  
  507. typedef void (_PFNMOD)(void);
  508. typedef _PFNMOD *PFNMOD;
  509.  
  510.  
  511. /***************************************************************************
  512.  *    The Thread class maintains runtime information about a thread.       *
  513.  ***************************************************************************/
  514.  
  515. // Thread reference class
  516. class ThreadRef
  517.       {
  518.       // Friend of Thread
  519.       friend class Thread;
  520.  
  521.       // Friend functions
  522.       friend void _Optlink GuiThreadShell (void *);
  523.  
  524.       private:
  525.       // Constructor & destructor
  526.       ThreadRef ();
  527.  
  528.       // Internal variables
  529.       HAB     hab;                               /* Thread anchor block    */
  530.       HMQ     hmq;                               /* Thread message queue   */
  531.       TID     tid;                               /* Thread ID              */
  532.       BOOL    bEnded;                            /* Thread ended flag      */
  533.       PFNMOD  pModule;                           /* Thread routine         */
  534.       HWND    hwndNotify;                        /* Window to notify       */
  535.       LONG    lCount;                            /* Reference count        */
  536.       };
  537.  
  538. class Thread 
  539.       {
  540.       public:
  541.       // Constructors & destructor
  542.       Thread ();
  543.      ~Thread ();
  544.       Thread (const Thread& thd);
  545.       Thread (ThreadRef *pRef);
  546.  
  547.       // Assignment operators
  548.       Thread& operator= (const Thread& thd);
  549.  
  550.       // Comparison operators
  551.       friend int operator== (const Thread& thd1, const Thread& thd2);
  552.       friend int operator!= (const Thread& thd1, const Thread& thd2);
  553.  
  554.       // Utility members functions
  555.       friend Thread GuiCreateThread (PFNMOD, LONG, PWINDOW);
  556.       BOOL Create (PFNMOD pModule, LONG lStack, HWND hwndNotify);
  557.       BOOL Destroy (void);
  558.       void Exit (LONG);
  559.       BOOL Sleep (void);
  560.       BOOL Wake (void);
  561.       BOOL Wait (void);
  562.       TID ID (void) const;
  563.  
  564.       // Internal routines
  565.       friend void _Optlink GuiThreadShell (void *);
  566.  
  567.       protected:
  568.       // Internal variables
  569.       ThreadRef *pRef;
  570.       };
  571.  
  572.  
  573. /***************************************************************************
  574.  *    Symbol pointer.                                                      *
  575.  ***************************************************************************/
  576.  
  577. #ifndef SYM_DEFINED
  578. typedef PVOID PSYM;
  579. #endif
  580.  
  581.  
  582. /***************************************************************************
  583.  *    Application information.                                             *
  584.  ***************************************************************************/
  585.  
  586. typedef struct _APPINFO
  587.         {      
  588.         HAB     hab;                             /* Main anchor block      */
  589.         HMQ     hmq;                             /* Main message queue     */
  590.         PID     pid;                             /* Current process ID     */
  591.         int     CmdArgC;                         /* Command line count     */
  592.         char  **CmdArgV;                         /* Command line args      */
  593.         HWND    hwndHelp;                        /* Help window            */
  594.         HWND    hwndMain;                        /* Main window            */
  595.         HWND    hwndSave;                        /* Saved focus window     */
  596.         char    szPgmTitle   [256];              /* Task-list title        */
  597.         char    szMsgFile    [256];              /* Message filename       */
  598.         char    szCurMsgFile [256];              /* Current message file   */
  599.         char    szHlpFile    [256];              /* Help filename          */
  600.         char    szCurHlpFile [256];              /* Current help file      */
  601.         char    szNxtHlpFile [256];              /* Next help file         */
  602.         HMODULE hmodNxtHelp;                     /* Next help module       */
  603.         SHORT   sExitCode;                       /* Program exit code      */
  604.         }
  605.         APPINFO, *PAPPINFO;
  606.  
  607.  
  608. /***************************************************************************
  609.  *    DLL instance information.                                            *
  610.  ***************************************************************************/
  611.  
  612. typedef struct _DLLINST
  613.         {
  614.         HMODULE hModule;                         /* DLL module handle      */
  615.         char    szMsgFile [256];                 /* DLL message file       */
  616.         char    szHlpFile [256];                 /* DLL help file          */
  617.         }
  618.         DLLINST, *PDLLINST;
  619.  
  620.  
  621. /***************************************************************************
  622.  *    Frame data (not stored in window words like other controls).         *
  623.  ***************************************************************************/
  624.  
  625. typedef struct _FRAMEWORDS
  626.         {
  627.         PFNWP    pfnwp;                          /* Frame window procedure */
  628.         LONG     lID;                            /* Frame window ID        */
  629.         SWP      swpOrig;                        /* Unscaled frame size    */
  630.         Image   *pMousePtr;                      /* Mouse pointer image    */
  631.         }
  632.         FRAMEWORDS, *PFRAMEWORDS;
  633.  
  634.  
  635. /***************************************************************************
  636.  *    Runtime error codes.                                                 *
  637.  ***************************************************************************/
  638.  
  639. #define GUIERR_OK            0                   /* No error               */
  640. #define GUIERR_OUTOFMEMORY   0x00000001          /* Out of memory          */
  641. #define GUIERR_DIVBYZERO     0x00000002          /* Divide by zero         */
  642. #define GUIERR_CANTLOADWIN   0x00000003          /* Cant load window       */
  643. #define GUIERR_NULLHWND      0x00000004          /* Window does not exist  */
  644. #define GUIERR_EVENTLOOP     0x00000005          /* Event loop overflow    */
  645. #define GUIERR_THDSTARTED    0x00000006          /* Thread already started */
  646. #define GUIERR_THDENDED      0x00000007          /* Thread already ended   */
  647. #define GUIERR_MAX           0x00000007          /* Max. error number      */
  648.  
  649.  
  650. /***************************************************************************
  651.  *    DDE error codes.                                                     *
  652.  ***************************************************************************/
  653.  
  654. #define GUIERR_DDEINVALIDCONN -1             /* Invalid Connection Handle  */
  655. #define GUIERR_DDEBUSY        -2             /* Connection is Busy         */
  656. #define GUIERR_DDESYSERROR    -3             /* System Error               */
  657. #define GUIERR_DDENOSERVERS   -4             /* No Servers Available       */
  658. #define GUIERR_DDETIMEOUT     -5             /* Time-out awaiting response */
  659. #define GUIERR_DDEINVALIDITEM -6             /* Invalid Item               */
  660. #define GUIERR_DDEOUTOFMEMORY -7             /* Not Enough Memory          */
  661.  
  662. /* A DDE Error Code above 0 is an application defined code */
  663.  
  664.  
  665. /***************************************************************************
  666.  *    RGB Colors.                                                          *
  667.  ***************************************************************************/
  668.  
  669. #define MAKERGB(r,g,b)      ((((ULONG)(r) & 0xFF) << 16) | \
  670.                              (((ULONG)(g) & 0xFF) << 8)  | \
  671.                              (((ULONG)(b) & 0xFF)))
  672.  
  673. #define RGB_DARKGRAY        MAKERGB(128, 128, 128)
  674. #define RGB_DARKBLUE        MAKERGB(  0,   0, 128)
  675. #define RGB_DARKRED         MAKERGB(128,   0,   0)
  676. #define RGB_DARKPINK        MAKERGB(128,   0, 128)
  677. #define RGB_DARKGREEN       MAKERGB(  0, 128,   0)
  678. #define RGB_DARKCYAN        MAKERGB(  0, 128, 128)
  679. #define RGB_BROWN           MAKERGB(128, 128,   0)
  680. #define RGB_PALEGRAY        MAKERGB(204, 204, 204)
  681.  
  682.  
  683. /***************************************************************************
  684.  *    Function Prototypes.                                                 *
  685.  ***************************************************************************/
  686.  
  687. extern   "C" int _CRT_init (void);
  688. extern   "C" void __ctordtorInit (void);
  689. ULONG   _System _DLL_InitTerm (HMODULE, ULONG);
  690.  
  691. PAPPINFO GuiAppInfo            (void);
  692. void     GuiInitApp            (PSZ, PSZ);
  693. void     GuiExitApp            (SHORT);
  694. void     GuiSetHlpFile         (PSZ, HMODULE);
  695. void     GuiSetMsgFile         (PSZ);
  696. void     GuiSaveCmdLine        (int, char *[]);
  697. SHORT    GuiCmdLineCnt         (void);
  698. String   GuiCmdLineArg         (SHORT);
  699. BOOL     GuiForever            (void);
  700. void     GuiDoNothing          (void);
  701.  
  702. PMESSAGE GuiNullMsg            (void);
  703. void     GuiSetMsg             (PMESSAGE, LONG, ULONG);
  704. String   GuiLoadMsg            (PMESSAGE);
  705. SHORT    GuiShowMsg            (PWINDOW, PMESSAGE, String, String);
  706. SHORT    GuiInvokeMsg          (PWINDOW, PMESSAGE);
  707.  
  708. void     GuiShowHelp           (SHORT);
  709. void     GuiShowHelpContents   (void);
  710. void     GuiShowHelpIndex      (void);
  711. void     GuiShowHelpForHelp    (void);
  712.  
  713. LONG     GuiRunProgram         (String, String, LONG);
  714. LONG     GuiWaitProgram        (LONG, SHORT);
  715.  
  716. LONG     GuiRandom             (LONG, LONG);
  717. void     GuiSeed               (LONG);
  718.  
  719. BOOL     GuiError              (LONG, LONG, PSZ);
  720. void     GuiDebug              (char *, ...);
  721. void     GuiDebugMsg           (char *, ULONG, MPARAM, MPARAM);
  722.  
  723. void     GuiInitWindows        (PAPPINFO);
  724. PWINDOW  GuiDesktopWindow      (void);
  725. PWINDOW  GuiObjectWindow       (void);
  726. PWINDOW  GuiNullWindow         (void);
  727. BOOL    _System GuiMsgFilter   (HAB, PQMSG, USHORT);
  728. void     GuiFillBackground     (HWND, HPS);
  729. LONG     GuiGetPresRGB         (HWND, ULONG, ULONG, LONG);
  730. void     GuiGetClientRect      (PWINDOW, PLONG, PLONG, PLONG, PLONG);
  731. void     GuiSetMousePtr        (HWND, HPOINTER);
  732. void     GuiSetCapture         (PWINDOW);
  733. SHORT    GuiInvokeWindow       (PWINDOW, PWINDOW);
  734. BOOL     GuiLoadWindow         (PWINDOW, PWINDOW);
  735. BOOL     GuiLoadWindow2        (PWINDOW);
  736. BOOL     GuiUnloadWindow       (PWINDOW);
  737. SHORT    GuiProcessWindow      (PWINDOW);
  738. void     GuiDismissWindow      (PWINDOW, SHORT);
  739. void     GuiActivateWindow     (PWINDOW);
  740. void     GuiGiveFocusWindow    (PWINDOW);
  741. void     GuiMaximizeWindow     (PWINDOW);
  742. void     GuiMinimizeWindow     (PWINDOW);
  743. void     GuiRestoreWindow      (PWINDOW);
  744. void     GuiGetWindow          (PWINDOW, HWND);
  745. void     GuiSetWindow          (PWINDOW, LONG, PSZ, PFNWP, HMODULE);
  746. void     GuiSetControl         (PWINDOW, PWINDOW, LONG, PSZ);
  747.                                
  748. void     GuiSetColor           (PWINDOW, LONG, LONG);
  749. LONG     GuiGetColor           (PWINDOW, LONG);
  750. void     GuiSetFont            (PWINDOW, String);
  751. String   GuiGetFont            (PWINDOW);
  752. BOOL     GuiFontAttrs          (PSZ, PFATTRS);
  753. LONG     GuiFontCount          (void);
  754. String   GuiEnumFonts          (LONG);
  755.                                
  756. SHORT    GuiGetShort           (PWINDOW, LONG);
  757. void     GuiSetShort           (PWINDOW, LONG, SHORT);
  758. LONG     GuiGetLong            (PWINDOW, LONG);
  759. void     GuiSetLong            (PWINDOW, LONG, LONG);
  760. double   GuiGetReal            (PWINDOW, LONG);
  761. void     GuiSetReal            (PWINDOW, LONG, REAL);
  762. String   GuiGetString          (PWINDOW, LONG);
  763. void     GuiSetString          (PWINDOW, LONG, String);
  764. Image    GuiGetImage           (PWINDOW, LONG);
  765. void     GuiSetImage           (PWINDOW, LONG, Image);
  766. PVOID    GuiGetPtr             (PWINDOW, LONG);
  767. void     GuiSetPtr             (PWINDOW, LONG, PVOID);
  768. LONG     GuiDataIndex          (HWND);
  769. MRESULT  GuiSendMsg            (HWND, ULONG, MPARAM, MPARAM);
  770. BOOL     GuiEventLoop          (MPARAM);
  771. BOOL     GuiTabbing            (HWND, ULONG, MPARAM, MPARAM);
  772. MRESULT  GuiDefFrameProc       (PFNWP, HWND, ULONG, MPARAM, MPARAM);
  773. MRESULT  GuiDefWinProc         (PFNWP, HWND, ULONG, MPARAM, MPARAM);
  774.  
  775. PMENTRY  GuiFrameCtlProc       (HWND, ULONG, MPARAM, MPARAM);
  776. PMENTRY  GuiMenuCtlProc        (HWND, ULONG, MPARAM, MPARAM);
  777. PMENTRY  GuiButtonCtlProc      (HWND, ULONG, MPARAM, MPARAM);
  778. PMENTRY  GuiComboboxCtlProc    (HWND, ULONG, MPARAM, MPARAM);
  779. PMENTRY  GuiEntryCtlProc       (HWND, ULONG, MPARAM, MPARAM);
  780. PMENTRY  GuiListboxCtlProc     (HWND, ULONG, MPARAM, MPARAM);
  781. PMENTRY  GuiMLECtlProc         (HWND, ULONG, MPARAM, MPARAM);
  782. PMENTRY  GuiScrollbarCtlProc   (HWND, ULONG, MPARAM, MPARAM);
  783. PMENTRY  GuiStaticCtlProc      (HWND, ULONG, MPARAM, MPARAM);
  784.                                
  785. SHORT    GuiInsertItem         (PWINDOW, SHORT, String);
  786. void     GuiDeleteItem         (PWINDOW, SHORT);
  787. void     GuiClearItems         (PWINDOW);
  788. String   GuiGetItemText        (PWINDOW, SHORT);
  789. void     GuiSetItemText        (PWINDOW, SHORT, String);
  790. LONG     GuiGetItemHandle      (PWINDOW, SHORT);
  791. void     GuiSetItemHandle      (PWINDOW, SHORT, LONG);
  792. void     GuiSelectItem         (PWINDOW, SHORT, BOOL);
  793. SHORT    GuiNextSelection      (PWINDOW, SHORT);
  794.                                
  795. int      GuiAbs                (int);
  796. SHORT    GuiAbs                (SHORT);
  797. LONG     GuiAbs                (LONG);
  798. SREAL    GuiAbs                (SREAL);
  799. REAL     GuiAbs                (REAL);
  800. LREAL    GuiAbs                (LREAL);
  801.  
  802. int      GuiMod                (int, int);
  803. SHORT    GuiMod                (SHORT, SHORT);
  804. LONG     GuiMod                (LONG, LONG);
  805. SREAL    GuiMod                (SREAL, SREAL);
  806. REAL     GuiMod                (REAL, REAL);
  807. LREAL    GuiMod                (LREAL, LREAL);
  808.  
  809. REAL     GuiInt                (REAL);
  810. REAL     GuiFrac               (REAL);
  811. REAL     GuiExp                (REAL);
  812. REAL     GuiLog                (REAL);
  813. REAL     GuiSqr                (REAL);
  814. REAL     GuiPow                (REAL, REAL);
  815. REAL     GuiFloor              (REAL);
  816. REAL     GuiCeil               (REAL);
  817. REAL     GuiSin                (REAL);
  818. REAL     GuiCos                (REAL);
  819. REAL     GuiTan                (REAL);
  820. REAL     GuiASin               (REAL);
  821. REAL     GuiACos               (REAL);
  822. REAL     GuiATan               (REAL);
  823. REAL     GuiPI                 (void);
  824. REAL     GuiDeg                (REAL);
  825. REAL     GuiRad                (REAL);
  826.                                
  827. LONG     GuiGetPS              (PWINDOW);
  828. void     GuiReleasePS          (LONG);
  829. void     GuiClearPS            (LONG);
  830. void     GuiMoveTo             (LONG, LONG, LONG);
  831. void     GuiLineTo             (LONG, LONG, LONG);
  832. void     GuiDrawLine           (LONG, LONG, LONG, LONG, LONG);
  833. void     GuiDrawBox            (LONG, LONG, LONG, LONG, LONG);
  834. void     GuiDrawCircle         (LONG, LONG, LONG);
  835. void     GuiDrawEllipse        (LONG, LONG, LONG, LONG);
  836. void     GuiDrawText           (LONG, String);
  837. void     GuiDrawImage          (LONG, Image, LONG);
  838. void     GuiSetDrawColor       (LONG, LONG);
  839. LONG     GuiGetDrawColor       (LONG);
  840. void     GuiSetBackColor       (LONG, LONG);
  841. LONG     GuiGetBackColor       (LONG);
  842. void     GuiSetSysColor        (LONG, LONG);
  843. LONG     GuiGetSysColor        (LONG);
  844. void     GuiSetLineType        (LONG, LONG);
  845. LONG     GuiGetLineType        (LONG);
  846. void     GuiSetFillPattern     (LONG, LONG);
  847. LONG     GuiGetFillPattern     (LONG);
  848.  
  849. /* DLL support */              
  850. BOOL     GuiRecordDLL          (PFN);
  851. void     GuiSetupDlls          (void);
  852.                                 
  853. /* DDE support */
  854. #ifdef INCL_PM
  855. SHORT   GuiDdeAcknowledge     (WINDOW *pWin,   HWND hwndOther, PSZ pszItem, SHORT sStatus);
  856. SHORT   GuiDdeAdvise          (WINDOW *pWin,   HWND hwndOther, PSZ pszItem, USHORT usFormat, BOOL bFlow, BOOL bData);
  857. SHORT   GuiDdeSendText        (WINDOW *pWin,   HWND hwndOther, PSZ pszItem, PSZ pszText, SHORT Response, SHORT AckReq);
  858. SHORT   GuiDdeExecute         (WINDOW *pWin,   HWND hwndOther, PSZ pszCommand);
  859. SHORT   GuiDdeInitiate        (WINDOW *pWin,   PSZ pszAppName, PSZ pszTopicName, ULONG ulTimeOut);
  860. SHORT   GuiDdeRespond         (WINDOW *pWin,   HWND hwndOther, PSZ pszAppName, PSZ pszTopicName);
  861. SHORT   GuiDdeRequest         (WINDOW *pWin,   HWND hwndOther, PSZ pszItem, USHORT usFormat);
  862. SHORT   GuiDdeTerminate       (WINDOW *pWin,   HWND hwndOther);
  863. SHORT   GuiDdeUnadvise        (WINDOW *pWin,   HWND hwndOther, PSZ pszItem, USHORT usFormat);
  864. PSZ     GuiDdeFetchTextItem   (WINDOW *pWin,   PDDESTRUCT pDdeStruct);
  865. SHORT   GuiDdeError           (PDDESTRUCT pDdeStruct);
  866. #endif /* INCL_PM */         
  867.  
  868.  
  869. #endif /* H_GUIRUN */
  870.  
  871.  
  872.  
  873.